import getProjStatusSheet from '../mock/testsheet';
import { getTestData } from '../mock/jira';
import getProjDetail from '../mock/project';
import JiraControllers from '../Controllers/JiraController';
import CONSTANTDATA from '../Tools/ResConstant';
import JiraModel from '../Models/JiraModel'

module.exports = router => {
        
  router.get('/api/testsheet', getProjStatusSheet);
  router.get('/api/currentUser', async function (ctx) {
    const data = {
      $desc: '获取当前用户接口',
      $params: {
        pageSize: {
          desc: '分页',
          exp: 2,
        },
      },
      $body: {
        name: 'Serati Ma',
        avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png',
        userid: '00000001',
        notifyCount: 12,
      },
    };
    ctx.body = data;
  });

  router.get('/api/project/:projectId', getProjDetail);
  router.get('/jira/bug/pandect', JiraControllers.bugPandect); // 返回Jira相关数据总览
  router.get('/jira/bug/pandect2/:projectid', async function(ctx){

    let projectid = await  ctx.params.projectid
    let res = await JiraModel.getSingleBugByJql(projectid);
    ctx.body= res
  }); 
  router.get('/test/pandect', getTestData);
  // 返回Jira单个项目相关数据总览
  router.get('/singleproject/bug/pandect/:projectid',JiraControllers.singleProjectData);
  // 返回质量系数总览
  router.get('/singleproject/qualityfactor/pandect',JiraControllers.QualityFactorArry);
  // 返回指定项目指定年份的每月Bug数
  router.get('/singleproject/bug/:year/:projectid',JiraControllers.eachProjectJiraDb);
  // 返回所有项目指定年份的每月Bug数
  router.get('/jira/monthbug/:year',JiraControllers.allProjectJiraDb)
}

